package cate.game.role.pvp.teampvp.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTeamPvp;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

@ClientMsg(title = "组队竞技发出组队邀请")
public class TeamPvpInviteApplyReq implements MsgInput {
    @NoteField("被邀请人的uid")
    public String invitedUid;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        if (StringUtils.isBlank(invitedUid)) {
            game.notice.message(cc.getRole(), "邀请的玩家不存在");
            return;
        }
        if (StringUtils.equals(invitedUid, cc.getRole().getUid())) {
            game.notice.message(cc.getRole(), "不能邀请自己噢");
            return;
        }
        GameResult r = game.pvp.teamPvp.inviteApply(cc.getRole(), invitedUid);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r);
        } else {
            game.notice.message(cc.getRole(), "已经发送邀请");
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTeamPvp.INVITE_APPLY_REQ;
    }
}
